<?php

namespace App;
/**
 * 消费者逻辑
 * @author walkor<walkor@workerman.net>
 */
class Worker
{
    /**
     * 模拟慢任务
     * 数据包格式： {"class":"Worker", "method":"operateData", "args":["v1","v2"]}
     * @return void
     */
    public function operateData($data)
    {
        //        以下的业务全部放到APP下的worker文件下的inDB函数内
        $messageArr = explode(',', $data);

//        $model = M("ws");

        $IMEI =$messageArr[1];

        $order_type =$messageArr[2];

        $order_code =$messageArr[3];

//		$is_exist = M('ws')->where(['client_id' => $client_id, 'imei' => $IMEI])->find();
//		if (!$is_exist) {
//			$insert_data = [
//				'client_id' => $client_id,
//				'imei' => $IMEI,
//				'create_time' => time()
//			];
//			$model->add($insert_data);
//
//			Gateway::bindUid($client_id, $IMEI);
//		}


//		$message_content = msg_content('A10*', $IMEI);
//		Gateway::sendToClient($client_id, $message_content);

//        $model_car = M('car');
//
//        $model_car_attr = M('car_attr');
//
//        $model_car_location_record = M('car_location_record');


        if ($order_type == 'AAA' && $order_code == 35) {//自动回调数据

            $mysqli = mysqli_connect('127.0.0.1', 'llc_bayuenet_co', 'ryzA7JHspDzMGHbc', 'llc_bayuenet_co', '3306');

            if (mysqli_connect_error()) {

                echo 'Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error;
                mysqli_close($mysqli);

            }

            if ($mysqli) {
                $select_database = mysqli_select_db($mysqli, 'llc_bayuenet_co');
                if ($select_database) {
                    mysqli_set_charset($mysqli, 'utf_8');
                } else {
                    echo "select database error";
                }
            } else {
                echo "connect error";
            }

            $carInfodata = mysqli_query($mysqli, "SELECT * FROM think_car WHERE equipment_no = '$IMEI'");
            if (!$carInfodata) {
                printf("Error: %s\n", mysqli_error($mysqli));
            }else{
                $carInfo = mysqli_fetch_all($carInfodata, MYSQLI_ASSOC);
            }

//            $carInfo = $model_car->where(['equipment_no' => $IMEI])->find();
            if (!empty($carInfo) && $messageArr[7] != 'V') {
                $carInfo_id = $carInfo[0]['id'];
                mysqli_query($mysqli, "UPDATE think_car SET status=3 WHERE id='$carInfo_id'");


//                $model_car->where(['id' => $carInfo])->setField('status', '3');

                $temArr = !empty($messageArr[23]) ? explode('|', $messageArr[23]) : [];


                //获取GPS消息中的时间日期

                $num_arr = str_split($messageArr[6]);
                $now_time = "20" . $num_arr[0] . $num_arr[1] . "-" . $num_arr[2] . $num_arr[3] . "-" . $num_arr[4] . $num_arr[5] . " " . $num_arr[6] . $num_arr[7] . ":" . $num_arr[8] . $num_arr[9] . ":" . $num_arr[10] . $num_arr[11];

                //转换温感器的温度
                $tamps = $messageArr[23];

                if (!empty($tamps)) {
                    $tamps_arr = explode('|', $tamps);
                    foreach ($tamps_arr as &$val) {
                        //获取后4位数字
                        $temp = str_split($val);
                        $temps = $temp[2] . $temp[3] . $temp[4] . $temp[5];

                        $nums = str_split(hexdec($temps));

                        $val = $nums[0] . $nums[1] . "." . $nums[2] . $nums[3];
                    }


                }

                //优化正常温度  -40~40
                //一区温度
                if (empty($tamps_arr[0]) or $tamps_arr[0]=="NULL") {
                    $now_times = strtotime($now_time);
                    $tamps_arr_onedate = mysqli_query($mysqli, "SELECT temperature_one FROM think_car_attr WHERE create_time <'$now_times' AND temperature_one BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                    if (!$tamps_arr_onedate) {
                        printf("Error: %s\n", mysqli_error($mysqli));
                    }else{
                        $tamps_arr_one = mysqli_fetch_all($tamps_arr_onedate, MYSQLI_ASSOC);

                    }

//                    $tamps_arr_one = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_one' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_one");
                } else {
                    if ($tamps_arr[0] < -40) {

                        $now_times = strtotime($now_time);
                        $tamps_arr_onedate = mysqli_query($mysqli, "SELECT temperature_one FROM think_car_attr WHERE create_time < '$now_times' AND temperature_one BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                        if (!$tamps_arr_onedate) {
                            printf("Error: %s\n", mysqli_error($mysqli));
                        }else{
                            $tamps_arr_one = mysqli_fetch_all($tamps_arr_onedate, MYSQLI_ASSOC);
                        }



//                        $tamps_arr_one = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_one' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_one");

                    } elseif ($tamps_arr[0] > 40) {

                        $now_times = strtotime($now_time);
                        $tamps_arr_onedate = mysqli_query($mysqli, "SELECT temperature_one FROM think_car_attr WHERE create_time < '$now_times' AND temperature_one BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                        if (!$tamps_arr_onedate) {
                            printf("Error: %s\n", mysqli_error($mysqli));
                        }else{
                            $tamps_arr_one = mysqli_fetch_all($tamps_arr_onedate, MYSQLI_ASSOC);
                        }


//                        $tamps_arr_one = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_one' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_one");
                    } else {
                        $tamps_arr_one = $tamps_arr[0];
                    }
                }

                //二区温度
                if (empty($tamps_arr[1]) or $tamps_arr[1]=="NULL") {

                    $now_times = strtotime($now_time);
                    $tamps_arr_twodate = mysqli_query($mysqli, "SELECT temperature_two FROM think_car_attr WHERE create_time < '$now_times' AND temperature_two BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                    if (!$tamps_arr_twodate) {
                        printf("Error: %s\n", mysqli_error($mysqli));
                    }else{
                        $tamps_arr_two = mysqli_fetch_all($tamps_arr_twodate, MYSQLI_ASSOC);
                    }



//                    $tamps_arr_two = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_two' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_two");
                } else {
                    if ($tamps_arr[1] < -40) {

                        $now_times = strtotime($now_time);
                        $tamps_arr_twodate = mysqli_query($mysqli, "SELECT temperature_two FROM think_car_attr WHERE create_time < '$now_times' AND temperature_two BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                        if (!$tamps_arr_twodate) {
                            printf("Error: %s\n", mysqli_error($mysqli));
                        }else{
                            $tamps_arr_two = mysqli_fetch_all($tamps_arr_twodate, MYSQLI_ASSOC);
                        }


//                        $tamps_arr_two = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_two' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_two");

                    } elseif ($tamps_arr[1] > 40) {

                        $now_times = strtotime($now_time);
                        $tamps_arr_twodate = mysqli_query($mysqli, "SELECT temperature_two FROM think_car_attr WHERE create_time < '$now_times' AND temperature_two BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                        if (!$tamps_arr_twodate) {
                            printf("Error: %s\n", mysqli_error($mysqli));
                        }else{
                            $tamps_arr_two = mysqli_fetch_all($tamps_arr_twodate, MYSQLI_ASSOC);
                        }



//                        $tamps_arr_two = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_two' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_two");
                    } else {
                        $tamps_arr_two = $tamps_arr[1];
                    }
                }

                //三区温度
                if (empty($tamps_arr[2]) or $tamps_arr[2]=="NULL") {

                    $now_times = strtotime($now_time);
                    $tamps_arr_threedate = mysqli_query($mysqli, "SELECT temperature_three FROM think_car_attr WHERE create_time < '$now_times' AND temperature_three BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                    if (!$tamps_arr_threedate) {
                        printf("Error: %s\n", mysqli_error($mysqli));
                    }else{
                        $tamps_arr_three = mysqli_fetch_all($tamps_arr_threedate, MYSQLI_ASSOC);
                    }



//                    $tamps_arr_three = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_three' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_three");
                } else {
                    if ($tamps_arr[2] < -40) {

                        $now_times = strtotime($now_time);
                        $tamps_arr_threedate = mysqli_query($mysqli, "SELECT temperature_three FROM think_car_attr WHERE create_time < '$now_times' AND temperature_three BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                        if (!$tamps_arr_threedate) {
                            printf("Error: %s\n", mysqli_error($mysqli));
                        }else{
                            $tamps_arr_three = mysqli_fetch_all($tamps_arr_threedate, MYSQLI_ASSOC);
                        }


//                        $tamps_arr_three = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_three' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_three");

                    } elseif ($tamps_arr[2] > 40) {

                        $now_times = strtotime($now_time);
                        $tamps_arr_threedate = mysqli_query($mysqli, "SELECT temperature_three FROM think_car_attr WHERE create_time < '$now_times' AND temperature_three BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                        if (!$tamps_arr_threedate) {
                            printf("Error: %s\n", mysqli_error($mysqli));
                        }else{
                            $tamps_arr_three = mysqli_fetch_all($tamps_arr_threedate, MYSQLI_ASSOC);
                        }


//                        $tamps_arr_three = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_three' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_three");
                    } else {
                        $tamps_arr_three = $tamps_arr[2];
                    }
                }

                //四区温度
                if (empty($tamps_arr[3]) or $tamps_arr[3]=="NULL") {

                    $now_times = strtotime($now_time);
                    $tamps_arr_fourdate = mysqli_query($mysqli, "SELECT temperature_four FROM think_car_attr WHERE create_time < '$now_times' AND temperature_four BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                    if (!$tamps_arr_fourdate) {
                        printf("Error: %s\n", mysqli_error($mysqli));
                    }else{
                        $tamps_arr_four = mysqli_fetch_all($tamps_arr_fourdate, MYSQLI_ASSOC);
                    }


//                    $tamps_arr_four = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_four' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_four");
                } else {
                    if ($tamps_arr[3] < -40) {

                        $now_times = strtotime($now_time);
                        $tamps_arr_fourdate = mysqli_query($mysqli, "SELECT temperature_four FROM think_car_attr WHERE create_time < '$now_times' AND temperature_four BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                        if (!$tamps_arr_fourdate) {
                            printf("Error: %s\n", mysqli_error($mysqli));
                        }else{
                            $tamps_arr_four = mysqli_fetch_all($tamps_arr_fourdate, MYSQLI_ASSOC);
                        }


//                        $tamps_arr_four = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_four' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_four");

                    } elseif ($tamps_arr[3] > 40) {
                        $now_times = strtotime($now_time);
                        $tamps_arr_fourdate = mysqli_query($mysqli, "SELECT temperature_four FROM think_car_attr WHERE create_time < '$now_times' AND temperature_four BETWEEN '-40' AND '40' AND car_id='$carInfo_id' ORDER BY id DESC");
                        if (!$tamps_arr_fourdate) {
                            printf("Error: %s\n", mysqli_error($mysqli));
                        }else{
                            $tamps_arr_four = mysqli_fetch_all($tamps_arr_fourdate, MYSQLI_ASSOC);
                        }



//                        $tamps_arr_four = M('car_attr')->where(['create_time' => array('lt', strtotime($now_time)), 'temperature_four' => array('between', '-40,40'), 'car_id' => $carInfo['id']])->order("id desc")->getField("temperature_four");
                    } else {
                        $tamps_arr_four = $tamps_arr[3];
                    }
                }


                //外接电压
                if (!empty($messageArr[18])) {
                    $voltage_sums = explode('|', $messageArr[18]);
                    //取第5个值  16进制转10进制  取整
                    $voltage_msg = hexdec($voltage_sums[4]);
                    //公式计算电压  取整
                    $voltage_now = round(($voltage_msg * 3.3 * 16) / 4096);
                }

                //停车时间
                if (empty($messageArr[10])) {
                    $stop_time_tams = mysqli_query($mysqli, "SELECT * FROM think_car_attr WHERE speed > 0 AND car_id='$carInfo_id' ORDER BY id DESC");
                    if (!$stop_time_tams) {
                        printf("Error: %s\n", mysqli_error($mysqli));
                    }else{
                        $stop_time_tam = mysqli_fetch_all($stop_time_tams, MYSQLI_ASSOC);
                    }

//                    $stop_time_tam = M('car_attr')->where(['speed' => array('gt', 0), 'car_id' => $carInfo['id']])->order("id desc")->find();
                    $stop_time = strtotime($now_time) - $stop_time_tam[0]['create_time'];
                } else {
                    $stop_time = 0;
                }

                //今日里程数
                if (!empty($messageArr[14])) {
                    $all_meal = $messageArr[14];
//                    $map['car_id'] = $carInfo['id'];
                    $maptime = array('lt', strtotime(date('Y-m-d', strtotime($now_time))));

                    $lastInfoss = mysqli_query($mysqli, "SELECT * FROM think_car_attr WHERE car_id='$carInfo_id' AND create_time < '$maptime' ORDER BY id DESC");
                    if (!$lastInfoss) {
                        printf("Error: %s\n", mysqli_error($mysqli));
                    }else{
                        $lastInfo = mysqli_fetch_all($lastInfoss, MYSQLI_ASSOC);
                    }

//                    $lastInfo = $model_car_attr->where($map)->order('id desc')->find();

                    $now_meal = ($all_meal - $lastInfo[0]['all_mileage']);
                    $today_mileage = empty($lastInfo) ? $all_meal : $now_meal;
                }

//                $insert_data = [
                $car_id = empty($carInfo[0]['id'])?'':$carInfo[0]['id'];
                $uid = empty($carInfo[0]['uid'])?'':$carInfo[0]['uid'];
                $all_mileage = empty($messageArr[14]) ? 0 : $messageArr[14];
                $speed = empty($messageArr[10]) ? '' : $messageArr[10];
                $electric = '';
                $humidity = '';
                $oil = empty($messageArr[22]) ? '' : $messageArr[22];
//					'temperature_one' => empty($temArr[0]) ? '' : (int)substr($temArr[0],2,4),
//					'temperature_two' => empty($temArr[1]) ? '' : (int)substr($temArr[1],2,4),
//					'temperature_three' => empty($temArr[2]) ? '' : (int)substr($temArr[2],2,4),
//					'temperature_four' => empty($temArr[3]) ? '' : (int)substr($temArr[3],2,4),
                $temperature_one = empty($tamps_arr_one[0]['temperature_one']) ? '' : $tamps_arr_one[0]['temperature_one'];
                $temperature_two = empty($tamps_arr_two[0]['temperature_two']) ? '' : $tamps_arr_two[0]['temperature_two'];
                $temperature_three = empty($tamps_arr_three[0]['temperature_three']) ? '' : $tamps_arr_three[0]['temperature_three'];
                $temperature_four = empty($tamps_arr_four[0]['temperature_four']) ? '' : $tamps_arr_four[0]['temperature_four'];
                $update_time = '';
                $cold_switch = '';
                $temperature_one_area = empty($temArr[0]) ? '' : (int)substr($temArr[0], 2, 4);
                $temperature_two_area = empty($temArr[1]) ? '' : (int)substr($temArr[1], 2, 4);
                $temperature_three_area = empty($temArr[2]) ? '' : (int)substr($temArr[2], 2, 4);
                $temperature_four_area = empty($temArr[3]) ? '' : (int)substr($temArr[3], 2, 4);
                $temperature_area = '';
                $humidity_one = '';
                $humidity_two = '';
                $humidity_three = '';
                $humidity_four = '';
                $all_m = $messageArr[14];
                $today_mileage = empty($today_mileage) ? 0 : $today_mileage;
                $status_time = '';
                $lng = $messageArr[5];
                $lat = $messageArr[4];
                $humidity_area = '';
                $create_time = strtotime($now_time);
                $stop_times = $stop_time;
                $door = '';
                $stop_address = '';
                $car_status = '';
                $voltage = $voltage_now;
                $electric_quantity = '';
//                ];


                $operation = mysqli_query($mysqli, "INSERT INTO think_car_attr
SET car_id='$car_id',uid='$uid',all_mileage='$all_mileage',speed='$speed',electric='$electric',humidity='$humidity',oil='$oil',temperature_one='$temperature_one',temperature_two='$temperature_two',temperature_three='$temperature_three',temperature_four='$temperature_four',update_time='$update_time',cold_switch='$cold_switch',temperature_one_area='$temperature_one_area',temperature_two_area='$temperature_two_area',temperature_three_area='$temperature_three_area',temperature_four_area='$temperature_four_area',temperature_area='$temperature_area',humidity_one='$humidity_one',humidity_two='$humidity_two',humidity_three='$humidity_three',humidity_four='$humidity_four',all_m='$all_m',today_mileage='$today_mileage',status_time='$status_time',lng='$lng',lat='$lat',humidity_area='$humidity_area',create_time='$create_time',stop_time='$stop_times',door='$door',stop_address='$stop_address',car_status='$car_status',voltage='$voltage',electric_quantity='$electric_quantity'");

//                $operation = $model_car_attr->add($insert_data);

//                if ($operation) {
//
//                    $model_car_attr->where(['id' => $operation])->setField('all_m', $messageArr[14]);
//
//                }

                //获取GPS消息中的时间日期

                $num_arr = str_split($messageArr[6]);
                $create_time = "20" . $num_arr[0] . $num_arr[1] . "-" . $num_arr[2] . $num_arr[3] . "-" . $num_arr[4] . $num_arr[5] . " " . $num_arr[6] . $num_arr[7] . ":" . $num_arr[8] . $num_arr[9] . ":" . $num_arr[10] . $num_arr[11];

//                $insert_data_location = [
                $location_uid = empty($carInfo[0]['uid'])?'':$carInfo[0]['uid'];
                $location_car_id = empty($carInfo[0]['id'])?'':$carInfo[0]['id'];
                $location_lng = $messageArr[5];
                $location_lat = $messageArr[4];
                $location_create_time = strtotime($create_time);
//                ];

                $operation_location = mysqli_query($mysqli, "INSERT INTO think_car_location_record SET uid='$location_uid',car_id='$location_car_id',lng='$location_lng',lat='$location_lat',create_time='$location_create_time'");

//                $model_car_location_record->add($insert_data_location);


            }
        }


        //出入围栏报警
        if ($order_code == 21 || $order_code == 20) {


            $carInfoinfo = mysqli_query($mysqli, "SELECT * FROM think_car WHERE equipment_no='$IMEI'");
            if (!$carInfoinfo) {
                printf("Error: %s\n", mysqli_error($mysqli));
            }else{
                $carInfo = mysqli_fetch_all($carInfoinfo, MYSQLI_ASSOC);
            }


//            $carInfo = $model_car->where(['equipment_no' => $IMEI])->find();

            if (!empty($carInfo)) {

//                $model_msg = M('message');
//
//                $model_car_enclosure = M('car_enclosure');
//                $model_car_enclosure_bind = M('car_enclosure_bind');

                $car_id = $carInfo[0]['id'];
                $numbers = $messageArr[19];

                $bindInfodate = mysqli_query($mysqli, "SELECT * FROM think_car_enclosure_bind WHERE car_id='$car_id' AND number='$numbers'");
                if (!$bindInfodate) {
                    printf("Error: %s\n", mysqli_error($mysqli));
                }else{
                    $bindInfo = mysqli_fetch_all($bindInfodate, MYSQLI_ASSOC);
                }


//                $bindInfo = $model_car_enclosure_bind->where(['car_id' => $carInfo['id'], 'number' => $messageArr[19]])->find();

                $type_text = $bindInfo['type'] == 1 ? '出区域报警' : '入区域报警';

//                $msg_data = [
                $message_uid = $carInfo[0]['uid'];
                $message_send_uid = '';
                $message_title = '围栏报警';
                $message_content = $type_text;
                $message_read_time = '';
                $message_is_read = '0';
                $message_type = 2;
                $message_create_time = time();
                $message_car_id = $carInfo[0]['id'];
                $message_warning_type = $bindInfo['type'];//出，2 入
//                ];

                mysqli_query($mysqli, "INSERT INTO think_message SET uid='$message_uid',send_uid='$message_send_uid',title='$message_title',content='$message_content',read_time='$message_read_time',is_read='$message_is_read',type='$message_type',create_time='$message_create_time',car_id='$message_car_id',warning_type='$message_warning_type'");


//                $add_id = $model_msg->add($msg_data);


//               $enclosure_insert_data = [
                $car_enclosure_car_id = $carInfo[0]['id'];
                $car_enclosure_uid = $carInfo[0]['uid'];
                $car_enclosure_intime = $bindInfo['type'] == 1 ? time() : '';
                $car_enclosure_outtime = $bindInfo['type'] == 2 ? time() : '';
                $car_enclosure_enclosure_id = $bindInfo['enclosure_id'];
                $car_enclosure_number = $messageArr[19];
//                ];

                mysqli_query($mysqli, "INSERT INTO think_car_enclosure SET car_id='$car_enclosure_car_id',uid='$car_enclosure_uid',intime='$car_enclosure_intime',outtime='$car_enclosure_outtime',enclosure_id='$car_enclosure_enclosure_id',number='$car_enclosure_number'");


//                $model_car_enclosure->add($enclosure_insert_data);
            }

        }
        /**
         * 包标识符数据长度 $$E159,     0
         * IMEI 866856038824809,     1
         * 指令类型 AAA,              2
         * 事件代码 35,               3
         * 纬度 22.512645,            4
         * 经度 114.057101,           5
         * 日期和时间 171005001107,      6
         * 定位状态 V,                  7
         * 卫星个数 0,                  8
         * GSM信号强度 24,              9
         * 速度 0,                    10
         * 方向 0,                    11
         * 水平定位精度 0.0,              12
         * 海拔高度 0,                  13
         * 里程数 0,                   14
         * 运行时间 1449012,            15
         * 基站信息 460|0|1813|00000798,16
         * 输入 输出口状态 0000,           17
         * 模拟量输入口值 0002|0000|0000|019E|0803,18
         * 事件辅助消息 00000001,         19
         * 定制数据 ,                   20
         * 协议版本 3,                  21
         * 油量百分比 ,                  22
         * 温度传感器,                   23
         * 最大加速度值 41,               24
         *
         * 76*64
         */

        // debug
//		echo "client:{$_SERVER['REMOTE_ADDR']}:{$_SERVER['REMOTE_PORT']} gateway:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']}  client_id:$client_id session:" . json_encode($_SESSION) . " onMessage:" . $message . "\n";
    }

    public function read()
    {
        // ..
    }
}